//! Header for the Client class
#ifndef CLIENT_H
#define CLIENT_H

#include <list>
#include "Object.h"
#include "RemoteControl.h"
#include "IDevice.h"

//typedef for a list of data type Device*
typedef std::list<IDevice*> TDevices;

//typedef for a list of data type ICommand*
typedef std::list<ICommand*> TCommands;

//! The Client manages all devices and implements a menu for
//! using the remote control
/*!
	This class is able to add devices to its device list
	and also programs the remote control. Programming the
	remote control contains a part of the test driver.
	The menu is used interactive. Device info can be output
	as well as undoing the last action and changing all available
	status of the devices.
	\class Client
	\author Andreas Lehner
	\date 27.12.2012
*/
class Client : public Object{
public:
	//! Add a device to the client
	/*!
		A device can be added to the list
		of the client. There is no limit for
		devices
	*/
	void AddDevice(IDevice * dev);
	//! Program the remote control
	/*!
		This function plays a part of the test driver.
		It programs the slots of a remote control.
	*/
	void ProgramRemoteControl();
	//! Function used for the interactive menu
	/*!
		User inputs will be asked for and depending
		on the input the output will follow. This includes
		output about state information of a device.
		Devices can be switched on/off and other states
		will also be executed on certain input.
	*/
	void UseRemoteControl();
private:
	//Frees all lists used by the Client
	void FreeLists();
	//free a device
	static void DeleteDevice(IDevice * dev);
	//free a command
	static void DeleteCommand(ICommand * com);
	//Add a command to the list of Commands
	void AddCommand(ICommand * com);
	//Print the user menu including the devices
	//and slot position on the remote control
	void PrintInterface();
	//Function used in for_each to output device info
	static void PrintDevice(IDevice * dev);
	//list of devices in the client
	//also used to free the devices
	TDevices mDevices;
	//commands that are used for the remote control
	//list for freeing the commands
	TCommands mCommands;
	//remote control used by the client
	RemoteControl mRemoteControl;
};

#endif